package com.foreknow.elmboot.mapper;


import com.foreknow.elmboot.po.Deliveryaddress;
import org.apache.ibatis.annotations.*;

import java.sql.SQLException;
import java.util.List;

@Mapper
public interface DeliveryaddressMapper {
    //根据用户编号查询所属送货地址
    @Select("select * from deliveryaddress where userid=#{userId}")
    public List<Deliveryaddress> dlistDeliveryAddressByUserId(Deliveryaddress deliveryaddress);

    //根据送货地址编号查询送货地址
    @Select("select * from deliveryaddress where daid=#{daId}")
    public Deliveryaddress dgetDeliveryAddressById(Deliveryaddress deliveryaddress);

    //向送货地址表中添加一条记录
    @Insert("insert into deliveryaddress(contactName,contactSex,contactTel,address,userId values(#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    public int dsaveDeliveryAddress(Deliveryaddress deliveryaddress);

    //根据送货地址编号更新送货地址信息
    @Update("update deliveryaddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address},userId=#{userId} where daid=#{daId}")
    public int dupdateDeliveryAddress(Deliveryaddress deliveryaddress);

    //根据送货地址编号删除一条记录
    @Delete("delete from deliveryaddress where daid=#{daId}")
    public int dremoveDeliveryAddress(Deliveryaddress deliveryaddress);

}
